package com.yueyang.sojourn.server.service.sojourn.order;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yueyang.sojourn.server.model.po.SojournOrderTourist;
import com.yueyang.sojourn.server.model.po.SojournTourist;
import com.yueyang.sojourn.server.service.sojourn.tourist.SojournTouristMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 游客服务
 * @author andy.yang
 * @version v1
 * @summary
 * @Copyright (c) 2019, yueyang Group All Rights Reserved.
 * @since 2020/3/17
 */
@Service
public class SojournOrderTouristService {
    @Resource
    SojournOrderTouristMapper sojournOrderTouristMapper;

    /**
     * 创建游客
     * @param tourist
     * @return
     */
    public Long add(SojournOrderTourist tourist){
        return sojournOrderTouristMapper.insert(tourist);
    }

    /**
     * 创建游客
     * @param tourists
     * @return
     */
    public int addBatch(List<SojournOrderTourist> tourists){
        return sojournOrderTouristMapper.batchInsert(tourists);
    }


    /**
     * @param userId      所属用户id
     * @return com.github.pagehelper.PageInfo<com.yueyang.sojourn.server.model.vo.SojournMerchVo>
     * @author Andy.yang
     * @summary 订单分页查询
     * @version v1
     * @since 2020-02-19
     */
    public List<SojournOrderTourist> findList(Long userId) {
        return sojournOrderTouristMapper.findBy(userId);
    }
    /**
     * @param orderId      所属订单id
     * @return com.github.pagehelper.PageInfo<com.yueyang.sojourn.server.model.vo.SojournMerchVo>
     * @author Andy.yang
     * @summary 订单分页查询
     * @version v1
     * @since 2020-02-19
     */
    public List<SojournOrderTourist> findByOrderId(Long orderId) {
        return sojournOrderTouristMapper.findByOrderId(orderId);
    }

    /**
     * @param orderTouristId      订单游客id
     * @return com.github.pagehelper.PageInfo<com.yueyang.sojourn.server.model.vo.SojournMerchVo>
     * @author Andy.yang
     * @summary 订单分页查询
     * @version v1
     * @since 2020-02-19
     */
    public SojournOrderTourist findById(Long orderTouristId) {
        return sojournOrderTouristMapper.selectByPrimaryKey(orderTouristId);
    }
}
